package cn.easytogo.tag;

import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.TagSupport;

public class TreeTag extends TagSupport
{

    public TreeTag()
    {
    }

    public void setIsEnableRadio(String s)
    {
        isEnableRadio = s;
    }

    public void setId(String s)
    {
        id = s;
    }

    public void setStyle(String s)
    {
        style = s;
    }

    public void setWidth(String s)
    {
        width = s;
    }

    public void setHeight(String s)
    {
        height = s;
    }

    public void setTreeImagePath(String s)
    {
        treeImagePath = s;
    }

    public void setIsEnableDrag(String s)
    {
        isEnableDrag = s;
    }

    public void setTreeSkin(String s)
    {
        treeSkin = s;
    }

    public void setIsShowContextMenu(String s)
    {
        isShowContextMenu = s;
    }

    public void setTreeDataMode(String s)
    {
        treeDataMode = s;
    }

    public void setTreeLoadUrl(String s)
    {
        treeLoadUrl = s;
    }

    public void setTreeAutoLoadUrl(String s)
    {
        treeAutoLoadUrl = s;
    }

    public void setMenuLoadUrl(String s)
    {
        menuLoadUrl = s;
    }

    public void setMenuImagePath(String s)
    {
        menuImagePath = s;
    }

    public void setMenuSkin(String s)
    {
        menuSkin = s;
    }

    public void setIsEnableCheckBoxes(String s)
    {
        isEnableCheckBoxes = s;
    }

    public void setIsEnableThreeStateCheckboxes(String s)
    {
        isEnableThreeStateCheckboxes = s;
    }

    public int doStartTag()
        throws JspException
    {
        try
        {
            StringBuffer stringbuffer = new StringBuffer(500);
            stringbuffer.append("<div ").append(outputProperties()).append("></div>");
            pageContext.getOut().write(stringbuffer.toString());
        }
        catch(Exception exception)
        {
            throw new JspException(exception);
        }
        return super.doStartTag();
    }

    private String outputProperties()
    {
        StringBuffer stringbuffer = new StringBuffer(100);
        stringbuffer.append("JSObjName=\"TREE\" ");
        if(id != null && !id.trim().equals(""))
            stringbuffer.append("id=\"").append(id).append("\" ");
        else
            stringbuffer.append("id=\"tree_").append(String.valueOf(1 + (int)(Math.random() * 100D))).append("\" ");
        if(style != null && !style.trim().equals(""))
            stringbuffer.append("style=\"").append(style).append("\" ");
        if(width != null && !width.trim().equals(""))
            stringbuffer.append("width=\"").append(width).append("\" ");
        if(height != null && !height.trim().equals(""))
            stringbuffer.append("height=\"").append(height).append("\" ");
        if(treeImagePath != null && !treeImagePath.trim().equals(""))
            stringbuffer.append(" treeImagePath=\"").append(treeImagePath).append("\" ");
        if(isEnableDrag != null && !isEnableDrag.trim().equals("") && isEnableDrag.trim().equalsIgnoreCase("true"))
            stringbuffer.append("isEnableDrag=\"").append("true").append("\" ");
        else
            stringbuffer.append("isEnableDrag=\"").append("false").append("\" ");
        if(isEnableCheckBoxes != null && !isEnableCheckBoxes.trim().equals("") && isEnableCheckBoxes.trim().equalsIgnoreCase("true"))
            stringbuffer.append("isEnableCheckBoxes=\"").append("true").append("\" ");
        else
            stringbuffer.append("isEnableCheckBoxes=\"").append("false").append("\" ");
        if(isEnableThreeStateCheckboxes != null && !isEnableThreeStateCheckboxes.trim().equals("") && isEnableThreeStateCheckboxes.trim().equalsIgnoreCase("true"))
            stringbuffer.append("isEnableThreeStateCheckboxes=\"").append("true").append("\" ");
        else
            stringbuffer.append("isEnableThreeStateCheckboxes=\"").append("false").append("\" ");
        if(null != isEnableRadio && isEnableRadio.trim().equalsIgnoreCase("true"))
            stringbuffer.append("isEnableRadio=\"").append("true").append("\" ");
        if(treeSkin != null && !treeSkin.trim().equals(""))
            stringbuffer.append("treeSkin=\"").append(treeSkin).append("\" ");
        if(isShowContextMenu != null && !isShowContextMenu.trim().equals("") && isShowContextMenu.trim().equalsIgnoreCase("true"))
            stringbuffer.append("isShowContextMenu=\"").append("true").append("\" ");
        else
            stringbuffer.append("isShowContextMenu=\"").append("false").append("\" ");
        if(treeDataMode != null && !treeDataMode.trim().equals(""))
            stringbuffer.append("treeDataMode=\"").append(treeDataMode).append("\" ");
        if(treeLoadUrl != null && !treeLoadUrl.trim().equals(""))
            stringbuffer.append("treeLoadUrl='").append(treeLoadUrl).append("' ");
        if(treeAutoLoadUrl != null && !treeAutoLoadUrl.trim().equals(""))
            stringbuffer.append("treeAutoLoadUrl=\"").append(treeAutoLoadUrl).append("\" ");
        if(menuLoadUrl != null && !menuLoadUrl.trim().equals(""))
            stringbuffer.append("menuLoadUrl=\"").append(menuLoadUrl).append("\" ");
        if(menuImagePath != null && !menuImagePath.trim().equals(""))
            stringbuffer.append("menuImagePath=\"").append(menuImagePath).append("\" ");
        if(menuSkin != null && !menuSkin.trim().equals(""))
            stringbuffer.append("menuSkin=\"").append(menuSkin).append("\" ");
        return stringbuffer.toString();
    }

    private static final long serialVersionUID = 6190818487397493934L;
    private String id;
    private String style;
    private String width;
    private String height;
    private String treeImagePath;
    private String isEnableDrag;
    private String treeSkin;
    private String isShowContextMenu;
    private String treeDataMode;
    private String treeLoadUrl;
    private String treeAutoLoadUrl;
    private String isEnableCheckBoxes;
    private String isEnableThreeStateCheckboxes;
    private String isEnableRadio;
    private String menuLoadUrl;
    private String menuImagePath;
    private String menuSkin;
}